package com.shiliang.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.shiliang.common.annotation.Log;
import com.shiliang.common.core.controller.BaseController;
import com.shiliang.common.core.domain.AjaxResult;
import com.shiliang.common.enums.BusinessType;
import com.shiliang.domain.Boundary;
import com.shiliang.service.IBoundaryService;
import com.shiliang.common.utils.poi.ExcelUtil;
import com.shiliang.common.core.page.TableDataInfo;

/**
 * 边界表Controller
 * 
 * @author shiliang
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/boundary/boundary")
public class BoundaryController extends BaseController
{
    @Autowired
    private IBoundaryService boundaryService;

    /**
     * 查询边界表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Boundary boundary)
    {
        startPage();
        List<Boundary> list = boundaryService.selectBoundaryList(boundary);
        return getDataTable(list);
    }

    /**
     * 导出边界表列表
     */
    @PreAuthorize("@ss.hasPermi('boundary:boundary:export')")
    @Log(title = "边界表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Boundary boundary)
    {
        List<Boundary> list = boundaryService.selectBoundaryList(boundary);
        ExcelUtil<Boundary> util = new ExcelUtil<Boundary>(Boundary.class);
        util.exportExcel(response, list, "边界表数据");
    }

    /**
     * 获取边界表详细信息
     */
    @PreAuthorize("@ss.hasPermi('boundary:boundary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(boundaryService.selectBoundaryById(id));
    }

    /**
     * 新增边界表
     */
    @PreAuthorize("@ss.hasPermi('boundary:boundary:add')")
    @Log(title = "边界表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Boundary boundary)
    {
        return toAjax(boundaryService.insertBoundary(boundary));
    }

    /**
     * 修改边界表
     */
    @PreAuthorize("@ss.hasPermi('boundary:boundary:edit')")
    @Log(title = "边界表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Boundary boundary)
    {
        return toAjax(boundaryService.updateBoundary(boundary));
    }

    /**
     * 删除边界表
     */
    @PreAuthorize("@ss.hasPermi('boundary:boundary:remove')")
    @Log(title = "边界表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(boundaryService.deleteBoundaryByIds(ids));
    }
}
